package tweet.response;

import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.Scene;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import desktop.agent.*;
import tweet.response.*;

 
var tweetResponse : TweetResponse = null;

var stage: Stage = null;
 
public function popWindow(myUser:String, message:String, sessionService:ServiceUtil, xIn:Long, yIn:Long, visible:String){
    var stageDragInitialX:Number;
    var stageDragInitialY:Number;
/*
	 var stage = Stage {
	            x: 40
	            y: 500
	        title: "Tweet"
	        style: StageStyle.TRANSPARENT
	
	        scene: Scene {
	
	            width: 340
	            height: 320
	
	            content: Group {
	                content: [ tweetResponse ]               
	           }
	            fill: Color.TRANSPARENT
	        }
	    }
*/
    //var tweetResponse : TweetResponse = TweetResponse {
    if (tweetResponse == null) {
       
       tweetResponse  = TweetResponse {
	        onMousePressed: function(e) {
	            if("{__PROFILE__}" != "browser") {
	                stageDragInitialX = e.screenX - stage.x;
	                stageDragInitialY = e.screenY - stage.y;
	            }
	        }
	        onMouseDragged: function(e) {
	                stage.x = e.screenX - stageDragInitialX;
	                stage.y = e.screenY - stageDragInitialY;
	        }
    	};
    	
		stage = Stage {
    	       	          
    		x: xIn
    	    y: yIn
    	    title: "Tweet"
    	    style: StageStyle.TRANSPARENT
    	        	
    	    scene: Scene {
    	    	width: 240
    	        height: 370
    	        content: Group {
    	        	content: [ tweetResponse ]               
				}
    	        fill: Color.TRANSPARENT
			}
		}
    	
    	tweetResponse.start(myUser, message, stage, sessionService);
    	//if (visible == null) {
    	//	tweetResponse.setInvisible();    
    	//} else {
    	//    tweetResponse.setVisible();
    	//}
    	tweetResponse.setVisible();
    	
    } else {
        stage.x = xIn;
		stage.y = yIn;
        println("Set message and response");
        tweetResponse.setText(message);
        tweetResponse.setVisible();
    }
 


   


    //tweetResponse.start(myUser, message, stage, sessionService);

}

